//
//  ADInputIntercepter.h
//  ADKitDemo
//
//  Created by adu on 2019/1/3.
//  Copyright © 2019 Fission. All rights reserved.
//

#import <UIKit/UIKit.h>

@class ADInputIntercepter;

typedef void(^ADIntercepterBlock) (ADInputIntercepter *intercepter, NSString *string);

typedef NS_OPTIONS(NSUInteger, ADIntercepterAllowType) {
    ADIntercepterAllowNumber = 1 << 0,//数字
    ADIntercepterAllowDecimal = 1 << 1,//小数
    ADIntercepterAllowLetter = 1 << 2,//字母
    ADIntercepterAllowChinese = 1 << 3,//汉字
    ADIntercepterAllowEmoji = 1 << 4,//表情
    ADIntercepterAllowSepical = 1 << 5,//特殊符号
    ADIntercepterAllowAll = 1 << 6,
};//允许输入类型

@interface UIView (InputIntercepter)

@property (nonatomic, strong) ADInputIntercepter *intercepter;

@end

@interface ADInputIntercepter : NSObject

@property (nonatomic, assign) NSUInteger minLength;//最小字符长度
@property (nonatomic, assign) NSUInteger maxLength;//最大字符长度

//长度计算方式
// YES:一个汉字=3个字节 表情=4个字节 NO:字母、数字、汉字都是1个字节 表情2个字节
// default is NO
@property (nonatomic, assign) BOOL doubleByteMode;

@property (nonatomic, assign) ADIntercepterAllowType allowType;

//长度不符合条件回调
@property (nonatomic, copy) ADIntercepterBlock lengthInterceptBlock;

//类型不符合条件回调
@property (nonatomic, copy) ADIntercepterBlock typeInterceptBlock;

//小数精确位数
// only vaild in ADIntercepterAllowDecimal
@property (nonatomic, assign) NSUInteger decimalPlaces;

//特殊字符 default is ’[~`!@#$%^&*()_+-=[]|{};':\",./<>?]{,}/‘
@property (nonatomic, copy) NSString *sepicalString;

//限制输入正则 会忽略allowType设置
@property (nonatomic, copy) NSString *regularStr;

+ (instancetype)intercepterWithInputView:(UIView *)inputView;

@end


